from win32com.client import Dispatch
import argparse
catVisPropertyPickAttr_ = 0
catVisPropertyNoPickAttr_ = 1

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("pickable", default="1")
    args = parser.parse_args()

    CATIA = Dispatch("CATIA.Application")


    drawingDoc = CATIA.ActiveDocument
    sheet = drawingDoc.Sheets.ActiveSheet
    View = sheet.Views.ActiveView
    texts_collection = View.Texts
    fac2d = View.Factory2D
    selection = CATIA.ActiveDocument.Selection
    selection.Clear()
    for i in range(1, texts_collection.Count + 1):
        text_ = texts_collection.Item(i)
        selection.Add(text_)
    if args.pickable == "1":
        print("unlock")
        selection.VisProperties.SetPick(catVisPropertyPickAttr_)
    else:
        print("lock")
        selection.VisProperties.SetPick(catVisPropertyNoPickAttr_)